package com.pashanhoo.datastructure.sort;

import java.util.Arrays;

/**
 * 二分查找
 */
public class BinarySearch {
    public static int rank(int key,int[] arr){

        int start = 0;
        int end = arr.length-1;
        int mid;
        while (true){
            mid = (start+end)/2;
            if (key<arr[mid]){
                end = mid-1;
            }else if (key>arr[mid]){
                start = mid+1;
            }else{
                return mid;
            }
        }


    }

}
